<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <title>OLAP TABLE</title>
    <link type="text/css" rel="stylesheet" href="../src/css/ecui.css?__ist__=1_0_10" />

    <style type="text/css">
        .my-select {width: 160px; height: 20px};
    </style>
</head>

<body style="font-size:12px">

    <div style="width:200px;height:100px" ecui="type:olap-table;id:table">
    </div>



    <script>
        var __DI__NS__S__ = window;
        __DI__NS__S__.WEB_ROOT = '../';
    </script>

    <script type="text/javascript" src="../asset-c/xcore-debug.js"></script>
    <script type="text/javascript" src="../asset-c/ecui-debug.js"></script>
    
    <script>
        function random() {
            return Math.round(Math.random() * 100000000) / 1000;
        }

        var tableData0 = {
             datasource: [
                [121, 12.3213, 232, 324323],
                [121, 12.3213, 232, 324323],
                [121, 12.3213, 232, 324323]
             ],
             colFields: [
                ['维度1-1', '层级2-1', '层级3-1', '标题1-1', '标题2-1', '标题3-1', '标题4-1']
             ],
             colDefine: [
                { width: 100 }, { width: 100 }, { width: 100 }, { width: 100 }, { width: 100 }, { width: 100 }, { width: 100 }
             ],
             rowHeadFields: [
                ['左标题1-1', '左标题2-1', '左标题3-1'],
                ['左标题1-2', '左标题2-2', '左标题3-2'],
                ['左标题1-3', '左标题2-3', '左标题3-3']
             ]
        };

        var tableData1 = {
             datasource: [
                [121, 12.3213, 232, 324323],
                [121, 12.3213, 232, 324323],
                [121, 12.3213, 232, 324323]
             ],
             colFields: [
                ['维度1-1', '层级2-1', '层级3-1', '标题1-1', '标题2-1', '标题3-1', '标题4-1'],
                ['维度1-2', '层级2-2', '层级3-2', '标题1-2', '标题2-2', '标题3-2', '标题4-2'],
                ['维度1-3', '层级2-3', '层级3-3', '标题1-3', '标题2-3', '标题3-3', '标题4-3']
             ],
             colDefine: [
                { width: 100 }, { width: 100 }, { width: 100 }, { width: 100 }, { width: 100 }, { width: 100 }, { width: 100 }
             ],
             rowHeadFields: [
                ['左标题1-1', '左标题2-1', '左标题3-1'],
                ['左标题1-2', '左标题2-2', '左标题3-2'],
                ['左标题1-3', '左标题2-3', '左标题3-3']
             ]
        };

        var tableData2 = {
             colFields: [
                [
                    '层级a',
                    '层级b',
                    '层级c',
                    { v: '维度1-1', colspan: 6 }, 
                    // [],  
                    // [],
                    // [], 
                    // [], 
                    // [], 
                    { v: '标题1-1', colspan: 4 },
                    // [], 
                    // [], 
                    // [], 
                    { v: '标题3-1', colspan: 4 }
                    // [],
                    // [],
                    // []
                ],
                [
                    '层级a',
                    '层级b',
                    '层级c',
                    { v: '维度1-2', colspan: 3 },
                    // [],
                    // [],
                    { v: '层级2-2', colspan: 3 },
                    // [],
                    // [],
                    { v: '层级3-2', colspan: 2 },
                    // [],
                    { v: '标题1-2', colspan: 2 }, 
                    // [],
                    { v: '标题2-2', colspan: 2 },
                    // [],
                    { v: '标题3-2', colspan: 2 }
                    // []
                ],
                [
                    '层级a',
                    '层级b',
                    '层级c',

                    '值1-3', 
                    '同比2-3', 
                    '环比3-3', 

                    '值1-3', 
                    '同比2-3', 
                    '环比3-3', 

                    '值1-3', 
                    '同比2-3', 

                    '值3-3', 
                    '环比4-3',

                    '值3-3',
                    '环比4-3',

                    '值1-3', 
                    '同比2-3' 
                ]
             ],
             colDefine: [
                { width: 1 }, 
                { width: 1 }, 
                { width: 1 }, 

                { width: 1 }, 
                { width: 120 }, 
                { width: 80 }, 
                { width: 120 }, 
                { width: 1 }, 
                { width: 1 }, 
                { width: 120 }, 
                { width: 1 }, 
                { width: 80 }, 
                { width: 1 }, 
                { width: 90 }, 
                { width: 1 }, 
                { width: 130 }, 
                { width: 115 }
             ],
             rowHeadFields: [
                [
                    { v: '左标题1-1', rowspan: 4, expanded: false }, 
                    { v: '左标题2-1', rowspan: 2, expanded: true }, // indent
                    '左标题3-1'
                ],
                [
                    // [], 
                    // [],
                    { v: '左标题3-3', expanded: false, indent: 1}
                ],
                [
                    // [], 
                    { v: '左标题2-1', rowspan: 2 },
                    '左标题3-3'
                ],
                [
                    // [], 
                    // [],
                    { v: '左标题3-n', expanded: false, indent: 2}
                ],
                [
                    { v: '左标题1-1', rowspan: 4 }, 
                    { v: '左标题2-1', rowspan: 2 },
                    '左标题3-1'
                ],
                [
                    // [], 
                    // [],
                    '左标题3-3'
                ],
                [
                    // [], 
                    { v: '左标题2-1', rowspan: 2 },
                    '左标题3-3'
                ],
                [
                    // [], 
                    // [],
                    '左标题3-3'
                ]
             ]
        };    
        tableData2.datasource = [];
        var length = tableData2.colDefine.length - tableData2.rowHeadFields[0].length;
        for (var i = 0, line; i < tableData2.rowHeadFields.length; i ++) {
            line = [];
            for (var j = 0; j < length; j ++) {
                line.push(random());
            }
            tableData2.datasource.push(line);
        }

        var table = ecui.get('table');
        table.render(tableData2);


/*
{
    "isTimeDim": false,
    "schemaName": "datainsight",
    "dimName": "Time",
    "dimTree": {
        "drillDown": false,
        "hasAll": false,
        "children": [
            {
                "drillDown": false,
                "hasAll": false,
                "children": [
                    {
                        "drillDown": false,
                        "hasAll": false,
                        "name": "all$Time",
                        "uniqName": "all$[Time]",
                        "caption": "全部",
                        "selected": false,
                        "isDrill": false
                    },
                    {
                        "drillDown": false,
                        "hasAll": false,
                        "children": [
                            {
                                "drillDown": false,
                                "hasAll": false,
                                "children": [
                                    {
                                        "drillDown": false,
                                        "hasAll": false,
                                        "name": "1",
                                        "uniqName": "[Time].[2012].[1].[1]",
                                        "caption": "1",
                                        "selected": false,
                                        "isDrill": false
                                    }
                                ],
                                "name": "1",
                                "uniqName": "[Time].[2012].[1]",
                                "caption": "1",
                                "selected": false,
                                "isDrill": false
                            }
                        ],
                        "name": "2012",
                        "uniqName": "[Time].[2012]",
                        "caption": "2012",
                        "selected": true,
                        "isDrill": false
                    },
                    {
                        "drillDown": false,
                        "hasAll": false,
                        "children": [
                            {
                                "drillDown": false,
                                "hasAll": false,
                                "children": [
                                    {
                                        "drillDown": false,
                                        "hasAll": false,
                                        "name": "1",
                                        "uniqName": "[Time].[2013].[1].[1]",
                                        "caption": "1",
                                        "selected": false,
                                        "isDrill": false
                                    }
                                ],
                                "name": "1",
                                "uniqName": "[Time].[2013].[1]",
                                "caption": "1",
                                "selected": false,
                                "isDrill": false
                            }
                        ],
                        "name": "2013",
                        "uniqName": "[Time].[2013]",
                        "caption": "2013",
                        "selected": true,
                        "isDrill": false
                    }
                ],
                "name": "Time",
                "uniqName": "[Time]",
                "caption": "Time",
                "selected": false,
                "isDrill": false
            },
            {
                "drillDown": false,
                "hasAll": true,
                "children": [
                    {
                        "drillDown": false,
                        "hasAll": false,
                        "name": "all$All Time.Weeklys",
                        "uniqName": "all$[Time.Weekly].[All Time.Weeklys]",
                        "caption": "全部",
                        "selected": false,
                        "isDrill": false
                    },
                    {
                        "drillDown": false,
                        "hasAll": false,
                        "children": [
                            {
                                "drillDown": false,
                                "hasAll": false,
                                "children": [
                                    {
                                        "drillDown": false,
                                        "hasAll": false,
                                        "name": "7",
                                        "uniqName": "[Time.Weekly].[2012].[1].[7]",
                                        "caption": "7",
                                        "selected": false,
                                        "isDrill": false
                                    }
                                ],
                                "name": "1",
                                "uniqName": "[Time.Weekly].[2012].[1]",
                                "caption": "1",
                                "selected": false,
                                "isDrill": false
                            }
                        ],
                        "name": "2012",
                        "uniqName": "[Time.Weekly].[2012]",
                        "caption": "2012",
                        "selected": false,
                        "isDrill": false
                    },
                    {
                        "drillDown": false,
                        "hasAll": false,
                        "children": [
                            {
                                "drillDown": false,
                                "hasAll": false,
                                "name": "all$2013",
                                "uniqName": "all$[Time.Weekly].[2013]",
                                "caption": "全部",
                                "selected": false,
                                "isDrill": false
                            },
                            {
                                "drillDown": false,
                                "hasAll": false,
                                "children": [
                                    {
                                        "drillDown": false,
                                        "hasAll": false,
                                        "name": "7",
                                        "uniqName": "[Time.Weekly].[2013].[1].[7]",
                                        "caption": "7",
                                        "selected": false,
                                        "isDrill": false
                                    }
                                ],
                                "name": "1",
                                "uniqName": "[Time.Weekly].[2013].[1]",
                                "caption": "1",
                                "selected": false,
                                "isDrill": false
                            },
                            {
                                "drillDown": false,
                                "hasAll": false,
                                "children": [
                                    {
                                        "drillDown": false,
                                        "hasAll": false,
                                        "name": "14",
                                        "uniqName": "[Time.Weekly].[2013].[2].[14]",
                                        "caption": "14",
                                        "selected": false,
                                        "isDrill": false
                                    }
                                ],
                                "name": "2",
                                "uniqName": "[Time.Weekly].[2013].[2]",
                                "caption": "2",
                                "selected": false,
                                "isDrill": false
                            }
                        ],
                        "name": "2013",
                        "uniqName": "[Time.Weekly].[2013]",
                        "caption": "2013",
                        "selected": false,
                        "isDrill": false
                    }
                ],
                "name": "Time.Weekly",
                "uniqName": "[Time.Weekly]",
                "caption": "Weekly",
                "selected": false,
                "isDrill": false
            }
        ],
        "name": "Time",
        "uniqName": "[Time]",
        "caption": "Time",
        "selected": false,
        "isDrill": false
    }
} */


    </script>
</body>

</html>